<?
require("config.php");

$location_status .= "| Edit";
$show_backnav = "newsletter_menu";
$menuname = NULL;
$menutarget = NULL;

if (NULL!=$action){

	$dir = "med_newsletter/";

		if ($PDF) myUpload($PDF,$PDF_name,$dir);
	
	
		if ($PDF_name == null) $PDF_name = $bk_PDF;

		if ($remove_PDF=="ture") $PDF_name=NULL;
	$Date = "$Year-$Month-$Day";

   $field = array(
	"code", 
	"date", 
	"subject", 
	"details","pdf","type",
	);


   $content = array(
	$Code,
	$Date,
	$Subject,
	$Details,$PDF_name,$type,
	);

	$exp = "id=$id";

   myUpdate($table,$field,$content,$exp);

   header("location:" . $rela_path . "share/msg.php?v=44");

   exit();

}else{

  if (!checkRecord($table,$id)){

	header("location:" . $rela_path . "share/msg.php?v=9002");

	exit();
  
  }

}


$Query = "SELECT 
code,
date,
subject, 
details, pdf, type
FROM $table WHERE id=$id LIMIT 1";

$r=myQuery($Query);

$Code=$r[0][0];
$Date=$r[0][1];
$Subject=$r[0][2];
$Details=$r[0][3];
$PDF=$r[0][4];
$type = $r[0][5];
require($rela_path . "inc/header.php");
require($rela_path . "bin/date.php");

?>



<form action="" method="post" enctype="multipart/form-data" name="form1">
<input name="action" type="hidden" value="edit">
<input name="Code" type="hidden" value="<?print($Code)?>">
<input name="id" type="hidden" value="<?print($id)?>">
<input name="old_Picture" type="hidden" value="<?print($Picture)?>">

<input name="bk_PDF" type="hidden" value="<?print($PDF)?>">


<table width="95%" border="0" align="center">
  <tr> 
    <td valign="top"> <table border="0" cellspacing="5" cellpadding="1">
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td class="tdheader">Code : </td>
            <td><?print($Code)?></td>
          </tr>
          <tr> 
            <td class="tdheader">Date :</td>
            <td><?print(FFPdate($Date))?></td>
          </tr>
          <tr> 
            <td class="tdheader">Subject :</td>
            <td><input type="text" class="text" name="Subject" size="56" value="<?print($Subject)?>"></td>
          </tr>
          <tr> 
            <td class="tdheader">Details : </td>
            <td><textarea class="text" name="Details" cols="55" rows="20"><?print($Details)?></textarea></td>
          </tr>
          <tr>
            <td class="tdheader">Type :</td>
            <td><select name="type" class="select">
                <option value="Denmark" <?php if ($type=="Denmark") { echo "selected"; } ?>>Denmark</option>
                <option value="Hong Kong" <?php if ($type=="Hong Kong") { echo "selected"; } ?>>Hong Kong</option>
              </select>
            </td>
          </tr>
          <tr>
            <td class="tdheader">File :</td>
            <td>
              <?=$PDF?>
              <br />
              <input type="file" class="text" name="PDF" size="45" />            </td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td> <input type="image" src="../../images/bt_cancel.gif" onClick="Redirect('newsletter_menu.php',1);return false;"> <input type="image" src="../../images/bt_save.gif">            </td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
        </table>
    </td>

  </tr>
</table>
<br>
<br>
<br>


</form>

<?
require($rela_path . "inc/footer.php");
?>
